home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / disk / cdrom / MusicBox-2.1os.lha / MusicBox / MusicBoxTimer.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-29  |  2.7 KB  |  83 lines

  1. /*
  2.  ##########################################################################
  3.  ####                                                                  ####
  4.  ####                        The MusicBox Project                      ####
  5.  ####                    ============================                  ####
  6.  ####                                                                  ####
  7.  #### MusicBoxTimer.c                                                  ####
  8.  ####                                                                  ####
  9.  #### Version 2.1os  --  September 29, 2000                            ####
  10.  ####                                                                  ####
  11.  #### Copyright (C) 1994  Thomas Dreibholz                             ####
  12.  ####               2000  Molbachweg 7                                 ####
  13.  ####                     51674 Wiehl                                  ####
  14.  ####                     Germany                                      ####
  15.  ####                                                                  ####
  16.  ####                     EMail: Dreibholz@bigfoot.com                 ####
  17.  ####                     WWW:   http://www.bigfoot.com/~dreibholz     ####
  18.  ####                                                                  ####
  19.  ##########################################################################
  20. */
  21. /***************************************************************************
  22.  *                                                                         *
  23.  *   This program is free software; you can redistribute it and/or modify  *
  24.  *   it under the terms of the GNU General Public License as published by  *
  25.  *   the Free Software Foundation; either version 2 of the License, or     *
  26.  *   (at your option) any later version.                                   *
  27.  *                                                                         *
  28.  ***************************************************************************/
  29.  
  30. /* MusicBox Timer-Task */
  31.  
  32. struct Task  *MainTask;
  33. struct Task  *TimerTask;
  34.  
  35. extern ULONG  ProcessSignalMask;
  36.  
  37. UBYTE         RemoveFlag;
  38.  
  39. void NewProcess()
  40. {
  41.  geta4();
  42.  
  43.  for(;;)
  44.   {
  45.    Signal(MainTask,ProcessSignalMask);
  46.    Delay(5);
  47.    if(RemoveFlag==1) break;
  48.   }
  49.  Forbid();
  50.  RemoveFlag=2;
  51.  Exit(0);
  52. }
  53.  
  54. int InitProzess()
  55. {
  56.  RemoveFlag=0;
  57.  MainTask=FindTask(NULL);
  58.  TimerTask=CreateProcess((APTR)NewProcess,1000,"musicbox-display.process",10);
  59.  if(TimerTask==NULL) return(1);
  60.  return(0);
  61. }
  62.  
  63. void EntferneProzess()
  64. {
  65.  REGISTER BOOL bool;
  66.  
  67.  if(TimerTask!=NULL)
  68.   {
  69.    Forbid();
  70.    RemoveFlag=1;
  71.    Permit();
  72.    bool=FALSE;
  73.    do
  74.     {
  75.      Delay(2);
  76.      Forbid();
  77.      if(RemoveFlag==2) bool=TRUE;
  78.      Permit();
  79.     } while(bool==FALSE);
  80.   }
  81. }
  82.  
  83.